﻿using System;
using System.ComponentModel;
using System.Resources;

using Microsoft.WowAddonStudio.Project.Import;

namespace Microsoft.WowAddonStudio.Project.Import
{
	/// <summary>
	/// This wizard page is used to select the import type in import wizard.
	/// </summary>
	public partial class ImportSelectorWizardPane : InnerPane
	{
		#region Public properties

		/// <summary>
		/// Type of import. Check <see cref="ImportType"/> enumeration for more details.
		/// </summary>
		public ImportType ImportType { get; private set; }

		#endregion

		#region Lifecycle methods

		/// <summary>
		/// Creates instances of <see cref="ImportSelectorWizardPane"/>.
		/// </summary>
		public ImportSelectorWizardPane()
		{
			InitializeComponent();
			SetActive += ImportSelectorWizardPane_SetActive;
			ImportType = ImportType.None;
		}

		#endregion

		#region Private member functions

		/// <summary>
		/// Handles the SetActive event of the ImportSelectorWizardPane control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
		private void ImportSelectorWizardPane_SetActive(object sender, CancelEventArgs e)
		{
			if (folderImportRadioButton.Checked || aceImportRadioButton.Checked)
			{
				SetWizardButtons(WizardButtons.Next | WizardButtons.Back);

				if (folderImportRadioButton.Checked)
					ImportType = ImportType.FolderImport;
				else if (folderImportRadioButton.Checked)
					ImportType = ImportType.AceImport;
			}
			else
			{
				SetWizardButtons(WizardButtons.Back);
			}
		}

		/// <summary>
		/// Handles the Load event of the ImportSelectorWizardPane control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void ImportSelectorWizardPane_Load(object sender, EventArgs e)
		{
			//Set captions from resources
			var res = new ResourceManager(typeof (ImportWizardResources));
			HeaderText = res.GetString("ImportTypeGroupBox");
			folderImportRadioButton.Text = res.GetString("FolderImportRadioButton");
			aceImportRadioButton.Text = res.GetString("AceImportRadioButton");
		}

		/// <summary>
		/// Handles the Click event of the folderImportRadioButton control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void folderImportRadioButton_Click(object sender, EventArgs e)
		{
			SetWizardButtons(WizardButtons.Next | WizardButtons.Back);
			ImportType = ImportType.FolderImport;
		}

		/// <summary>
		/// Handles the Click event of the aceImportRadioButton control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void aceImportRadioButton_Click(object sender, EventArgs e)
		{
			SetWizardButtons(WizardButtons.Next | WizardButtons.Back);
			ImportType = ImportType.AceImport;
		}

		#endregion
	}
}